/*
 * Projet industriel MBDS 2012 VAMP
 */
package com.vampmobile.android.db;

import org.json.JSONException;
import org.json.JSONObject;
import com.vampmobile.android.db.VampDatabase;
/*
 * Object Member
 */

public class Member {
	protected Long id=null;
	public String email;
	public String name;
	public String firstname;
	public String password;
	private JSONObject o;

	public Member() {
		o = new JSONObject();
	}
	public Member(JSONObject o) {
		this.o = o;
		email = o.optString(VampDatabase.MEMBER_EMAIL_COL);
		password = o.optString(VampDatabase.MEMBER_PASSWORD_COL);
		name = o.optString(VampDatabase.MEMBER_NAME_COL);
		firstname = o.optString(VampDatabase.MEMBER_FIRSTNAME_COL);
		id = o.optLong(VampDatabase.MEMBER_ID_COL);
	}
	public Long getId() {
		return id;
	}

	public JSONObject toJSONObject() {
		try {
			o.put(VampDatabase.MEMBER_EMAIL_COL, email);
		} catch (JSONException e) {
			e.printStackTrace();
		}
		try {
			o.put(VampDatabase.MEMBER_NAME_COL, name);
		} catch (JSONException e) {
			e.printStackTrace();
		}
		try {
			o.put(VampDatabase.MEMBER_FIRSTNAME_COL, firstname);
		} catch (JSONException e) {
			e.printStackTrace();
		}
		try {
			o.put(VampDatabase.MEMBER_PASSWORD_COL, password);
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return o;
	}
}
